using System;
using System.Collections.Generic;
using System.Text;
using CMS.BIZ;
using AAM.DAL;
using AAM.BIZ;
using AAM.SQL;

namespace CMS.BOP
{
    public class SqlBizForumProvider : SqlBizObjectProvider<BizForum>
    {

        public BizForum Read(int forumID) { return Read(new ObjectID(BizForum.ObjectType, new object[] { forumID })); }
        public BizForum Find(int forumID) { return Find(new ObjectID(BizForum.ObjectType, new object[] { forumID })); }
        public bool Delete(int forumID) { return Delete(new ObjectID(BizForum.ObjectType, new object[] { forumID })); }


        public List<BizForum> ReadAllByCategory(int? categoryID, string order)
        {
            Command command;
            string orderBy = " ORDER BY " + order;
            if (categoryID == null) command = Connection.CreateCommand("SELECT * FROM " + Table.TableName + " WHERE ForumCategoryID IS NULL" + orderBy);
            else
            {
                command = Connection.CreateCommand("SELECT * FROM " + Table.TableName + " WHERE ForumCategoryID=?" + orderBy);
                command.AddParameter(categoryID);
            }
            return CreateListFromCommand(command);
        }
        public List<BizForum> ReadAllByCategory(int? categoryID) { return ReadAllByCategory(categoryID, "ForumName"); }
    }
}
